﻿@inject BaseWebElement _baseWebElement;
@inject IHttpContextAccessor _httpContextAccessor;
@{
    var language = _baseWebElement.Currentlanguage;
    var CompanyName = _baseWebElement.GetWebElement(WebElementType.CompanyName)?.Value;
    var Email = _baseWebElement.GetWebElement(WebElementType.Email)?.Value;
    var banner = _baseWebElement.GetBanner();
    var webHomeSite = _baseWebElement.GetWebHome();
    ViewData["keywords"] = webHomeSite?.SeoKeywords;
    ViewData["description"] = webHomeSite?.SeoDescritions;
    var ProductClass = _baseWebElement.GetContentClass().Where(m => m.ClassType == (int)ClassType.Products && m.IsShow == 1).Take(4).ToList();
    var currentlanguageclass = language.IsDefault == 1 ? "/" : "/" + language.LanguageClass + "/";
    ViewData["Title"] = CompanyName;
    var product = _baseWebElement.GetProducts().Where(m => m.IsShow == 1).Take(8).ToList();
    var showcontentClass = _baseWebElement.GetContentClass().Where(m => m.IsShow == 1 && m.ClassType == (int)ClassType.Content).ToList();
}
<div class="wrapper">
    @if (banner != null&& banner.Count>0)
    {
        <div class="banner">
            <div class="swiper-container swiper_ind">
                <div class="swiper-button-prev prev_ind"></div>
                <div class="swiper-button-next next_ind"></div>
                <div class="swiper-wrapper">
                    @foreach (var item in banner)
                    {
                        <div class="swiper-slide">
                            <a href="@(!item.Url.IsNullOrWhiteSpace() ? item.Url:"javascript:;")"><img src="@(item.Img)"></a>
                        </div>
                    }
                </div>
                <div class="swiper-pagination page_ind"></div>
            </div>
        </div>
    }
    <div class="indAbout">
        <div class="container">
            <div class="tit">
                <h2>@_baseWebElement.QueryLanText("Home_About")</h2>
                <span></span>
            </div>
            @Html.Raw(webHomeSite?.AboutusText)
        </div>
    </div>
    @if (ProductClass != null && ProductClass.Count > 0)
    {
        <div class="indType" style="background-image: url(@(webHomeSite?.Background1.Replace("\\","/")));">
            <div class="container">
                <div class="tit">
                    <h2>@(_baseWebElement.QueryLanText("Home_ProductClass"))</h2>
                    <span></span>
                </div>
                <ul class="clearfix">
                    @foreach (var item in ProductClass)
                    {
                        <li>
                            <a href="@(currentlanguageclass)products/catelog/@(item.Id).html">
                                <div class="imgBox">
                                    <img src="@item.TitleImg" />
                                </div>
                                <P>@item.ClassName</P>
                            </a>
                        </li>
                    }
                </ul>
            </div>
        </div>
    }
    @if (product != null && product.Count > 0)
    {
        <div class="indProducts">
            <div class="container">
                <div class="tit">
                    <h2>@(_baseWebElement.QueryLanText("Home_Products"))</h2>
                    <span></span>
                </div>
                <div class="swiper-button-prev "><i class="iconfont">&#xe6df;</i></div>
                <div class="swiper-button-next"><i class="iconfont">&#xe603;</i></div>
                <div class="swiper-container swiperPro">
                    <div class="swiper-wrapper">
                        @foreach (var item in product)
                        {
                            <div class="swiper-slide">
                                <div class="imgBox">
                                    <a href="@(currentlanguageclass)products/detail/@(item.Id).html"><img src="@item.TitleImg"></a>
                                </div>
                                <div class="txtBox">
                                    <a href="@(currentlanguageclass)products/detail/@(item.Id).html">@item.ProName</a>
                                    @if (!item.CasNo.IsNullOrWhiteSpace())
                                    {
                                        <P>CAS：@item.CasNo</P>
                                    }
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    }
    <div class="indGood" style="background-image: url(@(webHomeSite?.Background2.Replace("\\","/")));">
        <div class="container">
            <p>@(_baseWebElement.QueryLanText("Home_Background2Title"))</p>
            <span></span>
            <h2>@(_baseWebElement.QueryLanText("Home_Background2Text"))</h2>
            <a href="@(currentlanguageclass)application">@(_baseWebElement.QueryLanText("Home_More"))</a>
        </div>
    </div>
    @if (showcontentClass != null && showcontentClass.Count > 0)
    {
        <div class="indApply">
            <div class="container">
                <div class="tit">
                    <h2>@(_baseWebElement.QueryLanText("Home_Domain"))</h2>
                    <span></span>
                </div>
                <ul class="clearfix">
                    @foreach (var item in showcontentClass)
                    {
                        <li>
                            <a href="@(currentlanguageclass+item.Path)">
                                <div class="imgBox">
                                    <img src="@item.TitleImg">
                                </div>
                                <div class="txtBox">
                                    <p>@item.ClassName</p>
                                </div>
                            </a>
                        </li>
                    }
                </ul>
            </div>
        </div>
    }
</div>

@section Scripts{ 
<script>
    if ($(".swiper_ind .swiper-slide").length > 1) {
        var mySwiper = new Swiper('.swiper_ind', {
            autoplay: 5000,
            pagination: '.page_ind',
            paginationClickable: true,
            prevButton: '.prev_ind',
            nextButton: '.next_ind',
        })
    } else {
        var mySwiper = new Swiper('.swiper_ind', {
            autoplay: false,
            pagination: '.page_ind',
            paginationClickable: true,
            prevButton: '.prev_ind',
            nextButton: '.next_ind',
        })
    }
</script>

}


